class MyThread1 extends Thread{
    @Override
    public void run() {
        System.out.println("通过创建一个Thread子类来创建线程");
    }
}

class MyThread2 implements Runnable{
    @Override
    public void run() {
        System.out.println("通过实现run方法来创建线程");
    }
}

public class Test{
    public static void main(String[] args) {
        MyThread1 t1 = new MyThread1();
        t1.start();

        MyThread2 t2 = new MyThread2();
        Thread t22 = new Thread(t2);
        t22.start();

        Thread t3 = new Thread(){
            @Override
            public void run() {
                System.out.println("通过匿名内部类来创建线程");
            }
        };
        t3.start();

        Thread t4 = new Thread(() -> {
            System.out.println("通过lambda表达式创建");
        });
        t4.start();

        Runnable r1 = new Runnable() {
            @Override
            public void run() {
                System.out.println("匿名内部类创建");
            }
        };

        Thread t5 = new Thread(r1);
        t5.start();
    }
}
